//
//  LXLTopIconBottomTitleButton.m
//  QA
//
//  Created by 李小龙 on 2017/6/7.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "LXLTopIconBottomTitleButton.h"

@implementation LXLTopIconBottomTitleButton


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    self.redPoint.left = self.imageView.right-3;
    self.redPoint.bottom = self.imageView.top+7;
    [self.redPoint.layer setCornerRadius:self.redPoint.height/2.0];
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self awakeFromNib];
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    [self createUI];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self createUI];
}

- (void)createUI {
    self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
    [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height+5 ,-self.imageView.frame.size.width, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
    [self setImageEdgeInsets:UIEdgeInsetsMake(-self.titleLabel.bounds.size.height-5, 0.0,0.0, -self.titleLabel.bounds.size.width)];//图片距离右边框距离减少图片的宽度，其它不边
    
//    [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height+self.titleLabel.bounds.size.height , -self.imageView.frame.size.width, 0.0, 0.0)];
//    [self setImageEdgeInsets:UIEdgeInsetsMake(-self.titleLabel.bounds.size.height, 0.5*self.titleLabel.bounds.size.width, 0, -0.5*self.titleLabel.bounds.size.width)];
}

@end
